package com.lxw.oa.service.serviceImpl;

import com.lxw.oa.entity.Menu;
import com.lxw.oa.mapper.MenuMapper;
import com.lxw.oa.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service("menuService")
@Transactional
public class MenuServiceImpl implements MenuService{

    @Autowired
    private MenuMapper menuMapper;

    @Override
    public List<Integer> getMenuIds(List<Integer> roleId) {
        return menuMapper.getMenuIds(roleId);
    }

    @Override
    public List<Menu> getMenus(List<Integer> menuIds) {
        if(menuIds.size()==0){
            return new ArrayList<Menu>();
        }else{
            return menuMapper.getMenus(menuIds);
        }
    }

    @Override
    public List<Menu> getTopMenus() {
        return menuMapper.getTopMenus();
    }

    @Override
    public List<Menu> getMenusByTopId(String menu_id) {
        return menuMapper.getMenusByTopId(menu_id);
    }

    @Override
    public List<Map<String,String>> getTopMenuList(){
        return menuMapper.getTopMenuList();
    }

    @Override
    public void menuAdd(Menu menu) {
        menuMapper.menuAdd(menu);
    }
    @Override
    public  void menuEdit(Menu menu){
        menuMapper.menuEdit(menu);
    }
    @Override
    public void menuDel(String id){
        menuMapper.menuDel(id);
    }
    
}
